package maxinshiSomeipTool20.dataMgr;

import ma.xin.shi.configurations.CM.CMConfig;
import ma.xin.shi.configurations.ECU.ECUConfig;
import ma.xin.shi.configurations.Service.ServiceConfig;
import ma.xin.shi.configurations.SomeipAction.SomeipActionConfig;
import maxinshiSomeipTool20.dataMgr.dataType.*;

public class DataManager {

    private final ECUConfig ecuConfig = new ECUConfig();
    private final ServiceConfig serviceConfig = new ServiceConfig();
    private final CMConfig cmConfig = new CMConfig();
    private final DataTypeConfig dataTypeConfig = new DataTypeConfig();
    private final SomeipActionConfig someipActionConfig = new SomeipActionConfig();

    // 私有构造函数，防止外部实例化
    private DataManager() {}

    // 获取单例实例
    public static DataManager getInstance() {
        return Holder.INSTANCE;
    }

    // 提供访问各个配置模块的方法
    public ECUConfig getECUConfig() { return ecuConfig; }
    public ServiceConfig getServiceConfig() { return serviceConfig; }
    public CMConfig getCMConfig() { return cmConfig; }
    public DataTypeConfig getDataTypeConfig() { return dataTypeConfig; }
    public SomeipActionConfig getSomeipActionConfig() { return someipActionConfig; }

    // 使用静态内部类实现线程安全的单例
    private static class Holder {
        private static final DataManager INSTANCE = new DataManager();
    }
}
